﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using ATEC.ATCoreNET.WPF;

namespace ExampleTestUI
{
    public class DockWindow : DockableWnd
    {
        static private DockWindow instance;

        public DockWindow(ATEC.ATCore.ATLoad belongingATLoad) 
        { 
            this.Content = new WPFDock_UserControl();
            this.Title = "wpf停靠示例";
            if(belongingATLoad != null) 
            {
                this.Attach(belongingATLoad, "WPF_DOCK测试", new System.Drawing.Size(100, 100));
            }
        }

        protected override void OnClosed(EventArgs e) 
        {
            base.OnClosed(e);

            this.Detach();
            instance = null;
        }

        public void InitAttach()
        {
            if (base.IsLoaded) 
            {
                MessageBox.Show("已打开");
            }

        }

        public static DockWindow OpenWindow(ATEC.ATCore.ATLoad belongingATLoad)
        {
            if (instance == null && belongingATLoad != null) 
            { 
                instance = new DockWindow(belongingATLoad);
            }

            return instance;
        }

        public static void CloseWindow()
        {
            if (instance != null)
            {
                instance.Close();
            }
        }
    }
}
